package pers.cj.pdos.controller;


import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.cj.pdos.controller.base.BaseController;
import pers.cj.pdos.controller.entity.ResponseList;
import pers.cj.pdos.entity.Company;
import pers.cj.pdos.service.IGoodsSnLogService;
import pers.cj.pdos.utils.PdosUtils;
import pers.cj.pdos.utils.Utils;
import pers.cj.pdos.vo.GoodsSnLogVo;
import pers.cj.pdos.vo.GoodsSnVo;
import pers.cj.pdos.vo.UserVo;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 操作sn的操作记录 前端控制器
 * </p>
 *
 * @author chenj
 * @since 2020-02-21
 */
@Controller
@RequestMapping("/house")
public class GoodsSnLogController extends BaseController {
    @Autowired
    IGoodsSnLogService goodsSnLogService;

    @ResponseBody
    @RequiresPermissions("goodsSn:query")
    @RequestMapping("/goodsSnLog/getList")
    public ResponseList getList(int page, int limit, String goodsId, String sn){
        if (Utils.isEmpty(goodsId) || Utils.isEmpty(sn)) {
            return ResponseList.fail("商品id和sn不能为空");
        }

        UserVo userVo = getLoginUserVo();
        List<Map> list = goodsSnLogService.listVoPage(page,
                limit,
                goodsId,
                sn,
                PdosUtils.getViewOtherStoreId(userVo,null),
                null);
        long count = goodsSnLogService.count(goodsId,
                sn,
                PdosUtils.getViewOtherStoreId(userVo,null),
                null);
        return ResponseList.success(count,list);
    }
}
